//
//  JonesButtonItem.m
//  HCWSDK
//
//  Created by 丁 一 on 2018/4/23.
//  Copyright © 2018年 丁 一. All rights reserved.
//

#import "JonesButtonItem.h"
#import "JonesClass.h"

@implementation JonesButtonItem

+(UIBarButtonItem *)PublicBarButtonItemPian{
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    negativeSpacer.width = -7;
    return negativeSpacer;
}

+(UIButton *)TinxingButton:(NSString *)title andaction:(SEL)action andtarget:(UIViewController *)target{
    UIButton *_TiXingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_TiXingButton setTitle:title forState:UIControlStateNormal];
    _TiXingButton.frame=CGRectMake(0, 0, 83, 27);
    _TiXingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_TiXingButton.titleLabel setFont:[UIFont boldSystemFontOfSize:17]];
    [_TiXingButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [_TiXingButton addTarget:target action:action  forControlEvents:UIControlEventTouchUpInside];
    _TiXingButton.backgroundColor=[UIColor clearColor];
    return _TiXingButton;
}

+(UIBarButtonItem *)NavZiButton:(NSString *)title andaction:(SEL)action andtarget:(UIViewController *)target andAlignment:(NSInteger)type{
    UIButton *_TiXingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_TiXingButton setTitle:title forState:UIControlStateNormal];
    if (type==0) {
        _TiXingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    }else if (type==1){
        _TiXingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    }else if (type==2){
        _TiXingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    }
    
    NSDictionary *dict = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:15.0]};
    CGSize size=[title boundingRectWithSize:CGSizeMake(300, 30) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size;
    _TiXingButton.frame=CGRectMake(0, 0, size.width+1, 30);
    _TiXingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_TiXingButton.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
    [_TiXingButton setTitleColor:[JonesClass stringTOColor:@"#e4bd07"] forState:UIControlStateNormal];
    [_TiXingButton addTarget:target action:action  forControlEvents:UIControlEventTouchUpInside];
    _TiXingButton.backgroundColor=[UIColor clearColor];
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:_TiXingButton];
    
    return menuButton;
}

+(UIBarButtonItem *)NavImgButton:(UIImage *)img andaction:(SEL)action andtarget:(UIViewController *)target{
    UIButton *_TiXingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _TiXingButton.frame=CGRectMake(0, 0, 27, 27);
    [_TiXingButton setImage:img forState:UIControlStateNormal];
    [_TiXingButton addTarget:target action:action  forControlEvents:UIControlEventTouchUpInside];
    _TiXingButton.backgroundColor=[UIColor clearColor];
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:_TiXingButton];
    
    return menuButton;
}


@end
